package Mash;/*Copyright (c)  Sergey Schekochikhin (Genocidicbunny)
 *Main created on Jul 25, 2009 1:46:23 AM
 */
import Mash.UI.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyListener;

public class MainGame {
	private MainMenu menu;
	private MainScreen main;
	private OptionsMenu options;
	private GameMain mainGame;
	public static void main(String args[]){
		SwingUtilities.invokeLater(new Runnable(){
        	public void run(){
        	new MainGame().buildGUI();
        }
      });
	}
	public void buildGUI(){
 	 	main = new MainScreen();
		menu = new MainMenu(new Dimension(1000,510));
		options = new OptionsMenu(this, new Dimension(1000, 510));
		main.getContentPane().setLayout(new CardLayout());
	 	main.getContentPane().add("Main Menu",menu);
		main.getContentPane().add("Options Menu", options);
        main.pack();
     	main.setLocationRelativeTo(null);
     	main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     	main.setVisible(true);
		menu.requestFocusInWindow();
		menu.setMain(this);
	}
	public void startGame(){
		menu = null;
		mainGame = new GameMain();
		mainGame.setLocationRelativeTo(null);
		mainGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		mainGame.setVisible(true);
		mainGame.requestFocus();	

	}
	public void showOptions(){
		/*options.setEnabled(true);
		options.setVisible(true);
		menu.setEnabled(false);*/
		menu.setVisible(false);
		options.setVisible(true);
		CardLayout cl = (CardLayout)main.getContentPane().getLayout();
		cl.show(main.getContentPane(), "Options Menu");
		options.requestFocusInWindow();
		System.out.println(options.getListeners(KeyListener.class));
		System.out.println(options.isVisible()+ " " + options.isEnabled());
	}
	public void showMainMenu(){
		/*options.setEnabled(false);
		options.setVisible(false);
		menu.setEnabled(true); */
		menu.setVisible(true);
		options.setVisible(false);
		CardLayout cl = (CardLayout)main.getContentPane().getLayout();
		cl.show(main.getContentPane(), "Main Menu");
		menu.requestFocusInWindow();
	}
}
